<template>
  <div>
    <div>
      {{ userInfo }}
    </div>
    <el-button type="success" @click="sendGetUserInfo">发送请求</el-button>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import 'element-plus/theme-chalk/el-message.css'

import { type IUsersMeData, apiUsersMe } from '@/service/study5/demo2'

const userInfo = ref<IUsersMeData>()

const sendGetUserInfo = async () => {
  try {
    const res = await apiUsersMe()

    if (res.code !== '2000') {
      throw new Error(res.msg)
    }
    userInfo.value = res.data
  } catch (e: any) {
    alert(e.message)
  }
}
</script>

<style lang="scss" scoped></style>
